package com.ssy.lingxi.settle.accounts.handler.validator;

import com.ssy.lingxi.settle.accounts.handler.annotation.ReconciliationStatusAnnotation;
import com.ssy.lingxi.settle.accounts.model.constant.ReconciliationStatusEnum;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;

/**
 * 对账单状态校验注解验证类
 * @author Saske
 * @version 2.0.0
 * @date 2021-12-8
 */
public class ReconciliationStatusValidator implements ConstraintValidator<ReconciliationStatusAnnotation,Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if(value == null) {
            return false;
        }
        return Arrays.stream(ReconciliationStatusEnum.values()).anyMatch(e -> e.getCode().equals(value));
    }
}
